/*
 * Jd_ListeClients.java
 *
 * Created on 30 avril 2008, 23:51
 */

package run;

import bo.EmployeInterne;
import bo.ListeEmployesInterne;
import bo.ListeTechniciens;
import bo.Technicien;
import boerrors.AdresseMinimumMultiplicityException;
import boerrors.CodePostalMinimumMultiplicityException;
import boerrors.ZoneMinimumMultiplicityException;
import java.rmi.RemoteException;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author  olivierm
 */
public class Jd_ListeEmployesInt extends javax.swing.JDialog {
    
    private DefaultTableModel _modele = new DefaultTableModel();
    private String[] colName = {"Matricule","Nom","Prénom","Email","Téléphone","Fonction","Rue","Numéro","Code Postal","Commune","Zone"};    
    
    /** Creates new form Jd_ListeClients */
    public Jd_ListeEmployesInt(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this._modele.setColumnIdentifiers(colName);               
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jXPanel1 = new org.jdesktop.swingx.JXPanel();
        jToolBar1 = new javax.swing.JToolBar();
        jbtn_ListeInterventions = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Liste des objets en mémoire");

        jPanel1.setBackground(new java.awt.Color(0, 102, 153));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setFont(new java.awt.Font("Tahoma", 3, 14));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Liste des Employés interne");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addContainerGap(203, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addContainerGap())
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        jXPanel1.setLayout(new java.awt.BorderLayout());

        jToolBar1.setRollover(true);

        jbtn_ListeInterventions.setText("Rafraichir");
        jbtn_ListeInterventions.setFocusable(false);
        jbtn_ListeInterventions.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbtn_ListeInterventions.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbtn_ListeInterventions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_ListeInterventionsActionPerformed(evt);
            }
        });
        jToolBar1.add(jbtn_ListeInterventions);

        jXPanel1.add(jToolBar1, java.awt.BorderLayout.NORTH);

        jTable1.setModel(_modele);
        jScrollPane1.setViewportView(jTable1);

        jXPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        getContentPane().add(jXPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtn_ListeInterventionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_ListeInterventionsActionPerformed
        try {

            String[] objTmp = new String[11];
            Vector<EmployeInterne> lstT = ListeEmployesInterne.getInstance().getListeEmployeInterne();
            for (int i = 0; i < lstT.size(); i++) {
                objTmp[0] =  String.valueOf(lstT.get(i).getMatricule());
                objTmp[1] = lstT.get(i).getNom();
                objTmp[2] = lstT.get(i).getPrenom();
                objTmp[3] = lstT.get(i).getEmail();
                objTmp[4] = lstT.get(i).getTelephone();
                objTmp[5] = lstT.get(i).getFonction();
                objTmp[6] = lstT.get(i).getAdresse().getRue();
                objTmp[7] = lstT.get(i).getAdresse().getNumero();
                objTmp[8] = lstT.get(i).getAdresse().getCodePostal().getCodePostal();
                objTmp[9] = lstT.get(i).getAdresse().getCodePostal().getVille();
                objTmp[10] = lstT.get(i).getAdresse().getCodePostal().getZone().getLibelleZone(); 

                this._modele.addRow(objTmp);
            }            
        } catch (ZoneMinimumMultiplicityException ex) {
            Logger.getLogger(Jd_ListeEmployesInt.class.getName()).log(Level.SEVERE, null, ex);
        } catch (CodePostalMinimumMultiplicityException ex) {
            Logger.getLogger(Jd_ListeEmployesInt.class.getName()).log(Level.SEVERE, null, ex);
        } catch (AdresseMinimumMultiplicityException ex) {
            Logger.getLogger(Jd_ListeEmployesInt.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            Logger.getLogger(Jd_ListeEmployesInt.class.getName()).log(Level.SEVERE, null, ex);
        }
       
        
    }//GEN-LAST:event_jbtn_ListeInterventionsActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Jd_ListeEmployesInt dialog = new Jd_ListeEmployesInt(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JToolBar jToolBar1;
    private org.jdesktop.swingx.JXPanel jXPanel1;
    private javax.swing.JButton jbtn_ListeInterventions;
    // End of variables declaration//GEN-END:variables
    
}
